﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;

using QLTTAN.DTO;
namespace QLTTAN.DAL
{
    public class LoaiDeThiDAL
    {
        ConnectionData conn;

        public DataTable LoaiDeThi_Load()
        {
            conn = new ConnectionData();
            return conn.GetData("LOAIDETHI_LOAD");
        }

        public int LoaiDeThi_Insert(LoaiDeThiDTO LDT_DTO)
        {
            conn = new ConnectionData();

            int Nparameter = 3;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];

            name[0] = "TenLoaiDe";
            value[0] = LDT_DTO.TenLoaiDe;
            name[1] = "MaLoaiCT";
            value[1] = LDT_DTO.MaLoaiCT;
            name[2] = "ThoiLuongThi";
            value[2] = LDT_DTO.ThoiLuongThi;

            return conn.UpdateData("LOAIDETHI_INSERT", name, value, Nparameter);
        }

        public int LoaiDeThi_Update(LoaiDeThiDTO LDT_DTO)
        {
            conn = new ConnectionData();

            int Nparameter = 4;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];

            name[0] = "MaLoaiDe";
            value[0] = LDT_DTO.MaLoaiDe;
            name[1] = "TenLoaiDe";
            value[1] = LDT_DTO.TenLoaiDe;
            name[2] = "MaLoaiCT";
            value[2] = LDT_DTO.MaLoaiCT;
            name[3] = "ThoiLuongThi";
            value[3] = LDT_DTO.ThoiLuongThi;

            return conn.UpdateData("LOAIDETHI_UPDATE", name, value, Nparameter);
        }

        public int LoaiDeThi_Delete(LoaiDeThiDTO LDT_DTO)
        {
            conn = new ConnectionData();

            int Nparameter = 1;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];

            name[0] = "MaLoaiDe";
            value[0] = LDT_DTO.MaLoaiDe;

            return conn.UpdateData("LOAIDETHI_DELETE", name, value, Nparameter);
        }
    }
}
